import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/generated/a.dart';
import 'package:finance_app/generated/l10n.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/common/app_spaces.dart';
import 'package:finance_app/src/utils/date_time_utils.dart';
import 'package:finance_app/src/widgets/common/tag_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';

class SubBillingItem extends StatelessWidget {
  final String currency;
  final String amount;
  final String companyName;
  final DateTime billDate;
  final String status;
  final bool isHistory;
  final VoidCallback onTap;

  SubBillingItem(
      {Key key,
      this.currency,
      this.amount,
      this.companyName,
      this.billDate,
      this.status,
      this.isHistory,
      this.onTap})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return PressedOpacityButton(
      padding: EdgeInsets.symmetric(horizontal: getDp(26), vertical: getDp(16)),
      color: Colors.white,
      borderRadius: BorderRadius.circular(getDp(10)),
      boxShadow: [
        BoxShadow(
          offset: Offset(0.0, getDp(2)),
          blurRadius: getDp(10),
          spreadRadius: -getDp(4),
          color: Colors.black.withOpacity(0.25),
        ),
      ],
      onPressed: onTap,
      child: Row(
        children: [
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Row(
                  children: [
                    Text(
                      '${isHistory == true ? '${S.current.paid}: ' : ''}\$$amount',
                      style: TextStyle(
                        color: aceBlackColor,
                        fontSize: isHistory == true ? getSp(16) : getSp(20),
                        fontWeight: FontWeight.w700,
                        height: 22 / 16,
                      ),
                    ),
                    AppSpaces.w15,
                    if (status != null)
                      NormalRedTagWidget(
                        content: status,
                      ),
                  ],
                ),
                Text(
                  '${isHistory == true ? S.current.payment_date : S.current.due}: ${DateTimeUtils.formatGlobalDateTime(billDate)}',
                  style: TextStyle(
                    color: aceBlackColor,
                    fontSize: getSp(16),
                    fontWeight: FontWeight.w400,
                    height: 22 / 16,
                  ),
                ),
                if (!isHistory && companyName != null && companyName != '')
                  Text(
                    companyName,
                    style: TextStyle(
                      color: aceBlackColor,
                      fontSize: getSp(16),
                      height: 22 / 16,
                    ),
                  ),
              ],
            ),
          ),
          RotatedBox(
            quarterTurns: 3,
            child: SvgPicture.asset(
              A.assetsImagesStyleArrowBlack,
              color: aceBlackColor,
              width: getDp(8),
              height: getDp(8),
            ),
          ),
        ],
      ),
    );
  }
}
